package com.yocard.yxyd.others;

import android.text.Editable;
import android.text.TextWatcher;
import android.widget.EditText;

/**
 * create by wgl 2019/05/14
 * 筛选条件的金额的EditText监听
 */
public class EditTextWatcher implements TextWatcher {
    private EditText editText;

    public EditTextWatcher(EditText editText) {
        this.editText = editText;
    }

    @Override
    public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

    }

    @Override
    public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {

    }

    @Override
    public void afterTextChanged(Editable editable) {
        String str = editable.toString();
        if (str.length() == 1 && str.startsWith(".")) {
            str = "0.";
            editText.setText(str);
            editText.setSelection(str.length());
        }
    }
}
